package org.example.springboot.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.sql.Timestamp;
import java.util.List;

/**
 * 评论实体类
 */
@Data
@Schema(description = "评论实体类")
public class Comment {
    @TableId(type = IdType.AUTO)
    @Schema(description = "自增主键")
    private Long id;
    
    @Schema(description = "用户ID")
    private Long userId;
    
    @Schema(description = "图书ID")
    private Long bookId;
    
    @Schema(description = "父评论ID(回复)")
    private Long parentId;
    
    @Schema(description = "评论内容")
    @NotBlank(message = "评论内容不能为空")
    @Size(max = 1000, message = "评论内容不能超过1000个字符")
    private String content;
    
    @Schema(description = "状态(0:已删除,1:正常)")
    private Integer status;
    
    @Schema(description = "创建时间")
    private Timestamp createTime;
    
    @Schema(description = "更新时间")
    private Timestamp updateTime;
    
    @TableField(exist = false)
    @Schema(description = "用户名")
    private String username;
    
    @TableField(exist = false)
    @Schema(description = "用户头像")
    private String avatar;
    
    @TableField(exist = false)
    @Schema(description = "回复列表")
    private List<Comment> replies;

    @TableField(exist = false)
    @Schema(description = "书名")
    private String bookTitle;
    @TableField(exist = false)
    @Schema(description = "图书封面")
    private String bookCover;

} 